//package com.yuntsg.paperana.utils.esutils;
//
//import co.elastic.clients.elasticsearch.ElasticsearchClient;
//import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
//import co.elastic.clients.elasticsearch._types.query_dsl.Query;
//import co.elastic.clients.elasticsearch._types.query_dsl.RangeQuery;
//import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest;
//import co.elastic.clients.json.JsonData;
//import co.elastic.clients.json.jackson.JacksonJsonpMapper;
//import co.elastic.clients.transport.ElasticsearchTransport;
//import co.elastic.clients.transport.rest_client.RestClientTransport;
//import common.util.VerifyUtil;
//import lombok.SneakyThrows;
//import org.apache.http.HttpHost;
//import org.elasticsearch.client.RestClient;
//
//import java.io.IOException;
//
///**
// * @Author: gcr
// * @Date: 2023/8/30 10:23
// */
//public class EsClient {
//
//
//    public static RestClient restClient = RestClient.builder(new HttpHost("172.25.0.230", 9200)).build();
//    public static RestClient restClientDao19 = RestClient.builder(new HttpHost("10.1.1.11", 9200)).build();
//    public static ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
//    public static ElasticsearchTransport transportDao19 = new RestClientTransport(restClientDao19, new JacksonJsonpMapper());
//    public static ElasticsearchClient client = new ElasticsearchClient(transport);
//    public static ElasticsearchClient clientDao19 = new ElasticsearchClient(transportDao19);
//
//    public static ElasticsearchClient client() {
//        if (VerifyUtil.isNewDao19Server()) {
//            return clientDao19;
//        } else {
//            return client;
//        }
//
//    }
//
//
//    public static void clientOff() throws IOException {
//        // 关闭连接
//        if (VerifyUtil.isNewDao19Server()) {
//            transportDao19.close();
//            restClientDao19.close();
//        } else {
//            transport.close();
//            restClient.close();
//        }
//
//    }
//
//
//    @SneakyThrows
//    /**
//     * 删除库下面所有数据
//     */ public static void deleEsDataIndex(String index) {
//        ElasticsearchClient client = EsClient.client();
//        BoolQuery.Builder allQueryBuilder = new BoolQuery.Builder();
//        Query rangeQuery = RangeQuery.of(i -> i.field("id").gte(JsonData.fromJson("0")))._toQuery();
//        allQueryBuilder.must(rangeQuery);
//        Query query = allQueryBuilder.build()._toQuery();
//        DeleteByQueryRequest deleteByQueryRequest = DeleteByQueryRequest.of(s -> s.index(index).query(query));
//        client.deleteByQuery(deleteByQueryRequest);
//    }
//
//
//}
